<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
    <link rel="shortcut icon" href="newtemplatesfiles5/img/favicon.html">

    <title>电动车行驶证</title>

    <!-- Bootstrap core CSS -->
    <link href="newtemplatesfiles5/css/bootstrap.min.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="newtemplatesfiles5/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="newtemplatesfiles5/css/style.css" rel="stylesheet">
    <link href="newtemplatesfiles5/css/style-responsive.css" rel="stylesheet" />

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="newtemplatesfiles5/js/html5shiv.js"></script>
      <script src="newtemplatesfiles5/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--header start-->
      <div th:insert="common/student-common-header::top"></div>
      <!--header end-->
      <!--sidebar start-->
      <div th:insert="common/student-common-sidebar::#left"></div>
      <!--sidebar end-->
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper">
              <!-- page start-->
              <div class="row">
                  <!--student-info-left  start-->
                  <div th:insert="common/student-info-left::#student-info-left"></div>
                  <!--student-info-left  end-->
                  <aside class="profile-info col-lg-9">
                      <!--widget start-->
                      <section class="panel">
                          <div class="twt-feed blue-bg">
                              <h1>我的电动车行驶证</h1>
                              <p id="drivingLicenseID" th:text="${session.drivingLicenseImpl eq null ?
                              session.getDrivingLicenseMessage:session.drivingLicenseImpl.drivingLicenseID}">jsmith@flatlab.com</p>
                              <a href="#">
                                  <img th:src="${session.drivingLicenseImpl eq null ? 'asserts/img/YSU.jpg':session.drivingLicenseImpl.image}" alt="">
                              </a>
                          </div>
                          <br><br>
                          <div class="panel-body bio-graph-info">
                              <div class="row">
                                  <div class="bio-row">
                                      <label>姓名 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.studentName}"> Jonathan</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>学号 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.studentID}"> Jonathan</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>学院 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.department}"> Smith</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>审批人 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.approverName}"> Smith</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>车牌号 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.ebickID}"> UI Designer</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>品牌 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.brand}"> Australia</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>状态 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.status}"> UI Designer</a>
                                  </div>
                                  <div class="bio-row">
                                      <label>生效时间 :</label><a th:text="${session.drivingLicenseImpl eq null ? '':session.drivingLicenseImpl.generateTime}"> 13 July 1983</a>
                                  </div>
                              </div>
                              <footer class="twt-footer">
                                  <!--th:href="@{/toCancel.do(drivingLicenseID=${session.drivingLicenseImpl.drivingLicenseID})}"-->
                                  <a >
                                  <button class="btn btn-danger btn-info pull-right" type="button" onclick="toCancel()">
                                      <i class="icon-minus-sign"></i>
                                      注销
                                  </button></a>
                              </footer>
                          </div>

                      </section>
                      <!--widget end-->

                      <!--隐藏   注销理由   注销时显示-->
                      <section id="toWriteReason" class="panel" style="visibility: hidden">
                          <header class="panel-heading">
                              请填写注销原因
                          </header>
                          <div class="panel-body">
                              <form class="form-horizontal" role="form" id="myForm">
                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">证件号</label>
                                      <div class="col-lg-10">
                                          <input  name="drivingLicenseID" type="text" class="form-control" th:value="${session.drivingLicenseImpl eq null ?
                              session.getDrivingLicenseMessage:session.drivingLicenseImpl.drivingLicenseID}" disabled>
                                      </div>
                                  </div>
                                  <div class="form-group">
                                      <label class="col-lg-2 control-label">注销原因</label>
                                      <div class="col-lg-10">
                                          <input name="cancelReason" id="reason" type="text" class="form-control"  placeholder="" >
                                          <a  id="a-reason"  th:text="请填写注销原因" style="color: red;visibility: hidden"></a>
                                      </div>
                                  </div>
                              </form>
                              <div class="form-group">
                              <div class="col-lg-offset-2 col-lg-10">

                                  <button type="submit" class="btn btn-danger" onclick="applicationCancel()">申请注销</button>
                                  <button type="submit" class="btn btn-info" onclick="cancelOperation()">取消操作</button>
                              </div>
                          </div>
                          </div>
                      </section>
                  </aside>
              </div>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->

  </section>
  <script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script src="asserts/js/popper.min.js"></script>
  <script src="asserts/js/feather.min.js"></script>
  <script src="asserts/js/bootstrap.min.js"></script>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="newtemplatesfiles5/js/jquery.js"></script>
    <script src="newtemplatesfiles5/js/bootstrap.min.js"></script>
    <script src="newtemplatesfiles5/js/jquery.scrollTo.min.js"></script>
    <script src="newtemplatesfiles5/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="newtemplatesfiles5/assets/jquery-knob/js/jquery.knob.js"></script>

    <!--common script for all pages-->
    <script src="newtemplatesfiles5/js/common-scripts.js"></script>

  <script>

      function toCancel() {
            var drivingLicenseID = document.getElementById("drivingLicenseID").innerText;
            console.log(drivingLicenseID);
            var form = new FormData();
            form.append("drivingLicenseID",drivingLicenseID);
            $.ajax({
              url:"toCancel.do",
              type:"post",
              dataType:"html",
              data:form,
              cache:false,
              processData:false,
              contentType:false,
              success: function (data) {
                  console.log("success");
                  console.log(data);
                  if(data=="yes"){
                      toWriteReason();
                  }else{
                      alert("当前不能注销");
                  }
              },
              error:function (data) {
                  //alert("提交失败");
                  console.log("error");
              }
            })

      }

      function cancelOperation() {
          document.getElementById("toWriteReason").style.visibility="hidden";
      }
      function toWriteReason() {

              document.getElementById("toWriteReason").style.visibility="visible";

      }

      function applicationCancel() {

          var reason = document.getElementById("reason").value;
          console.log(reason.length);
          if(reason.length<1){
              console.log("请填写注销原因");
              document.getElementById("a-reason").style.visibility="visible";
          }else{
              document.getElementById("a-reason").style.visibility="hidden";
          }
          console.log("reason");
          console.log(reason);

          alert("确定申请注销吗？");
          var form = new FormData(document.getElementById("myForm"));
          console.log(form);
          form.append("drivingLicenseID",document.getElementById("drivingLicenseID").innerText);
          $.ajax({
              url:"cancelDrivingLicense.do",
              type:"post",
              dataType:"html",
              data:form,
              cache:false,
              processData:false,
              contentType:false,
              success: function (data) {
                  console.log(data);
                  if(data!="success"){
                      alert(data);
                  }else{
                      alert("提交成功，等待验证");
                      location.href="getDrivingLicenseImpl";
                  }
              },
              error:function (data) {
                  alert("提交失败");
                  console.log("error");
              }
          })

      };

      window.onload=function(){
          $("#li1").removeClass('active');
          $("#li2").addClass('active');
          $("#li3").removeClass('active');
          $("#li4").removeClass('active');
          $("#li5").removeClass('active');
          $("#li6").removeClass('active');
          $("#li7").removeClass('active');

      };
      //knob
      $(".knob").knob();

  </script>


  </body>
</html>
